import React, { useState } from 'react';
import { Table, Tag, Space, Modal, Button, PageHeader, Statistic, Row, Descriptions } from 'antd';

import taskHistory from '../mock/taskHistory';

const columns = [
    {
        title: '迭代轮次',
        dataIndex: 'iter',
        key: 'iter',
    },
    {
        title: '正确率',
        dataIndex: 'acc',
        key: 'acc',
    },
    {
        title: '全局模型IPFS地址',
        dataIndex: 'address',
        key: 'address',
    },
    {
        title: '全局模型交易HASH',
        dataIndex: 'SCaddress',
        key: 'address',
        render: (text: any, record: any) => (
            <a>{text}</a>
        ),
    },
    {
        title: '操作',
        key: 'action',
        render: (text: any, record: any) => (
            <Space size="middle">
                <a>查看详情</a>
            </Space>
        ),
    },
];


export const History = () => {

    const expandedRowRender = () => {
        const ecolumns = [
            { title: '客户端节点', dataIndex: 'peer', key: 'peer' },
            { title: '本地模型IPFS地址', dataIndex: 'IPFSaddres', key: 'IPFSaddres' },
            {
                title: '本地模型交易HASH', dataIndex: 'SCaddres', key: 'SCaddres', render: (text: any, record: any) => (
                    <a>{text}</a>
                ),
            },
        ];

        const data = [{
            key: 1,
            peer: '127.0.0.1:6002',
            SCaddres: '0xff510e9aa14b6bb6e66b8ba829bf52990a821f49b8ec435a4dc5962b9e80b35c',
            IPFSaddres: 'QmXCtfXbtz4usVS9jVN18Akn9E6Nw4sdxXmiryn68kBrWM',
        }, {
            key: 2,
            peer: '127.0.0.1:6005',
            SCaddres: '0x9783ca818e927618fcb87f18e8c3e93f731ebc5c8c29cb3aee246dc991109337',
            IPFSaddres: 'QmeLdCFseAyusdJbfqQ9XPWSS9aNxrAmfX3MkX1XMcCYjK',
        }, {
            key: 3,
            peer: '127.0.0.1:6007',
            SCaddres: '0x7a1c84757cf09d9e0574c22746c7dd6975df5a6e75e3d8c8fbec00f6b64f957f',
            IPFSaddres: 'QmVhDKsgKWUc2ejFn3WkXotwowiLbZuz9TP6o4V5tG2jgB',
        },
        ];
        return <Table columns={ecolumns} dataSource={data} pagination={false} />;
    };


    return (
        <div>
            <div>
                <Table columns={columns} dataSource={taskHistory} rowKey="iter" expandable={{ expandedRowRender }} />
            </div>
        </div>
    )
}

